#define _CRT_SECURE_NO_WARNINGS 1
void inorder(struct TreeNode* root, int* arr, int* returnSize)
{
    if (!root)
        return;
    inorder(root->left, arr, returnSize);
    arr[(*returnSize)++] = root->val;
    inorder(root->right, arr, returnSize);
}

bool isUnivalTree(struct TreeNode* root) {
    int arr[100];
    int returnSize = 0;
    inorder(root, arr, &returnSize);
    for (int i = 0; i < returnSize - 1; ++i)
    {
        if (arr[i] != arr[i + 1])
        {
            return false;
        }
    }
    return true;

}